package net.butfly.bus.config.bean;

import net.butfly.bus.server.ServerConfig;

public class TxBean {
	private String code;

	private String version;

	private String[] nodeAry;

	public TxBean(String code, String version, String[] nodes) {
		this.code = code;
		this.version = version != null ? version : "1.0";
		this.nodeAry = nodes;
	}

	public String getKey() {
		return ServerConfig.getServiceKey(code, version);
	}

	public String getCode() {
		return code;
	}

	public String getVersion() {
		return version;
	}

	public String[] getNodeAry() {
		return nodeAry;
	}

	public boolean matching(String txCode) {
		return code.equals(txCode) || (code.endsWith("*") && txCode.startsWith(code.substring(0, code.indexOf("*"))));
	}
}
